package ru.alt22.visor.php.unittests.core;

import java.util.Enumeration;
import java.util.Vector;

public class PHPTestSuite implements PHPTest {
	private Vector<PHPTest> tests = new Vector<PHPTest>();
	private String name;

	public PHPTestSuite(String name) {
		setName(name);
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void addTest(PHPTest test) {
		tests.addElement(test);
	}

	public Enumeration<PHPTest> tests() {
		return tests.elements();
	}

	public Vector<PHPTest> getTests() {
		return tests;
	}

	public int countTestCases() {
		int count = 0;
		for (Enumeration<PHPTest> e = tests(); e.hasMoreElements(); ) {
			PHPTest test = e.nextElement();
			count = count + test.countTestCases();
		}
		return count;
	}

	public void run(PHPTestResult result, PHPProxy proxy) {
		result.testSuiteStarted(this);
		for (Enumeration<PHPTest> e = tests(); e.hasMoreElements(); ) {
	  		if (result.shouldStop()) {
	  			break;
	  		}
			PHPTest test = e.nextElement();
			
			test.run(result, proxy);
		}
		result.testSuiteFinished(this);
	}

	public PHPTestCaseResult getResult() {
		return null;
	}

}